from BaseController import BaseController
from Utility import ParameterKey


class ChangePasswordController(BaseController):
    """
    Only accept post request
    """
    def post(self):
        oldPassword = self.request.get(ParameterKey.OLD_PASSWORD)
        newPassword = self.request.get(ParameterKey.NEW_PASSWORD)

        u = self.GetCurrentUser()
        if u is None:
            return # return F

        if u.Password == oldPassword:
            u.Password = newPassword
            u.put()
            return # return true

        return # return F
